package com.wfuhui.modules.store.controller;

import java.util.List;
import java.util.Map;

import com.wfuhui.modules.store.entity.StoreEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.modules.store.entity.CooperateEntity;
import com.wfuhui.modules.store.service.CooperateService;
import com.wfuhui.common.utils.Query;
import com.wfuhui.common.utils.R;




/**
 * 商务洽谈
 * 
 * @author lizhengle
 * @email codemax@qq.com
 * @date 07-27 07:52:48
 */
@RestController
@RequestMapping("/mall/cooperate")
public class CooperateController {
	@Autowired
	private CooperateService cooperateService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("mall:cooperate:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<CooperateEntity> cooperateList = cooperateService.queryList(query);
		int total = cooperateService.queryTotal(query);
		
		return R.ok().put("rows", cooperateList).put("total", total);
		
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("mall:cooperate:info")
	public R info(@PathVariable("id") Integer id){
		CooperateEntity cooperate = cooperateService.queryObject(id);
		
		return R.ok().put("cooperate", cooperate);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("mall:cooperate:save")
	public R save(@RequestBody CooperateEntity cooperate){
		cooperateService.save(cooperate);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("mall:cooperate:update")
	public R update(@RequestBody CooperateEntity cooperate){
		cooperateService.update(cooperate);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("mall:cooperate:delete")
	public R delete(@RequestBody Integer[] ids){
		cooperateService.deleteBatch(ids);
		
		return R.ok();
	}

	@RequestMapping("/examine")
	@RequiresPermissions("mall:cooperate:update")
	public R examine(Integer id, Integer status, String followUp) {
		CooperateEntity cooperate = new CooperateEntity();
		cooperate.setId(id);
		cooperate.setStatus(status);
		cooperate.setFollowUp(followUp);
		cooperateService.update(cooperate);
		return R.ok();
	}
	
}
